package com.guchenbo.demo.jdbc.service;

import com.guchenbo.demo.jdbc.dao.mapper.User2Mapper;
import com.guchenbo.demo.jdbc.dao.pojo.User2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author guchenbo
 * @Date 2020/3/23.
 */
@Service
public class User2ServiceImpl implements User2Service {
    @Autowired
    private User2Mapper user2Mapper;

    @Override
    @Transactional(noRollbackFor = Exception.class)
    public void addRequired(User2 user) {
        user2Mapper.insert(user);
    }

    @Override
    public void addRequiredException(User2 user) {
        user2Mapper.insert(user);
        throw new RuntimeException();
    }
}
